//
//  MeGuanYuViewController.m
//  NBProduct
//
//  Created by hl on 15/11/16.
//  Copyright (c) 2015年 ping. All rights reserved.
//

#import "MeGuanYuViewController.h"
//#import "DaoHangViewController.h"
#import "YinDaoViewController.h"
#import "LibWebViewViewController.h"

@interface MeGuanYuViewController ()<UITableViewDataSource,UITableViewDelegate,UIActionSheetDelegate>{
    UITableView    *table;
    UIActionSheet  *_myActionSheet;
    UIActionSheet  *_touSuActionSheet;
    NSString       *phoneNum;
}

@end

@implementation MeGuanYuViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor colorWithRed:240/255.0 green:239/255.0 blue:237/255.0 alpha:1];
    [self drawNavWithTitle:nil WithColor:[UIColor whiteColor]];
    [self drawBackButton];
    [self drawView];
    [self requestData];
    [self initActionSheet];
    // Do any additional setup after loading the view.
}
-(void)requestData{
    
//    [NetWorking jieKouQingQiu:KFDH And:nil anBlock:^(NSDictionary *dic, NSError *error) {
//        if (!error) {
//            if ([[dic objectForKey:Code]intValue] == 200) {
//                NSLog(@"--->%@",[dic objectForKey:Response]);
//                NSArray *resultArr = [NSArray arrayWithArray:[dic objectForKey:Response]];
//                for (NSDictionary *myDic in resultArr) {
//                    [_myActionSheet addButtonWithTitle:[myDic objectForKey:@"name"]];
//                }
//            }
//        }
//    }];
}
-(void)initActionSheet{
    _myActionSheet = [[UIActionSheet alloc] initWithTitle:@"工作时间9:00-18:00" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:nil, nil];
    
    _touSuActionSheet = [[UIActionSheet alloc] initWithTitle:@"工作时间9:00-18:00" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles:nil, nil];
    //13356073898   13356008588
    [_touSuActionSheet addButtonWithTitle:@"13356073898"];
    [_touSuActionSheet addButtonWithTitle:@"13356008588"];
//    [_myActionSheet addButtonWithTitle:@"2222222"];
}
-(void)drawView{
    UIImageView *appImageView = [[UIImageView alloc] initWithFrame:CGRectMake(KScreenWidth/2 - 50 * _kscW, 100 * _kscH, 100 * _kscW, 100 * _kscW)];
    appImageView.layer.cornerRadius = 4;
    appImageView.clipsToBounds = YES;
    appImageView.image = [UIImage imageNamed:@"未涞商城80"];
    [self.view addSubview:appImageView];
    
    UILabel *banBenLab = [[UILabel alloc] initWithFrame:CGRectMake(10 * _kscW, appImageView.bottom + 10 * _kscH, KScreenWidth - 20 * _kscW, 10 * _kscH)];
    
    NSDictionary *infoDict = [[NSBundle mainBundle] infoDictionary];
    
    NSString *nowVersion = [infoDict objectForKey:@"CFBundleShortVersionString"];
    
    banBenLab.text = [NSString stringWithFormat:@"未涞商城:v%@",nowVersion];
    banBenLab.font = [UIFont systemFontOfSize:12.0];
    banBenLab.textColor = [UIColor grayColor];
    banBenLab.textAlignment = NSTextAlignmentCenter;
    [self.view addSubview:banBenLab];
    
    UILabel *line = [[UILabel alloc] initWithFrame:CGRectMake(5 * _kscW, banBenLab.bottom + 10 * _kscH, KScreenWidth - 10 * _kscW, 1)];
    line.backgroundColor = ZONGCOLOR;
    [self.view addSubview:line];
    
    table = [[UITableView alloc] initWithFrame:CGRectMake(0, line.bottom +15 * _kscH, KScreenWidth, 160*_kscH) style:UITableViewStylePlain];
    table.delegate = self;
    table.dataSource = self;
    table.scrollEnabled = NO;
    [self.view addSubview:table];
    
    UILabel *signLab = [[UILabel alloc] initWithFrame:CGRectMake(0, KScreenHeight - 60 * _kscH, KScreenWidth, 12 * _kscH)];
    signLab.font = [UIFont systemFontOfSize:11.0];
    signLab.textColor = [UIColor grayColor];
    signLab.textAlignment = NSTextAlignmentCenter;
    signLab.text = @"嘉兴市西灰内电子商务有限公司";
    [self.view addSubview:signLab];
    
    UILabel *signLab2 = [[UILabel alloc] initWithFrame:CGRectMake(0, signLab.bottom + 5 * _kscH, KScreenWidth, 15 * _kscH)];
    signLab2.font = [UIFont systemFontOfSize:11.0];
    signLab2.textColor = [UIColor grayColor];
    signLab2.textAlignment = NSTextAlignmentCenter;
    signLab2.text = @"Copyright ©";
    [self.view addSubview:signLab2];
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 4;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
    cell.textLabel.textColor = [UIColor grayColor];
    cell.textLabel.font = [UIFont systemFontOfSize:13.0];
    if (indexPath.row == 0) {
        cell.textLabel.text = @"欢迎页";
    }else if(indexPath.row == 1){
        cell.textLabel.text = @"客服电话";
    }else if(indexPath.row == 2){
        cell.textLabel.text = @"投诉电话";
    }else{
        cell.textLabel.text = @"未涞商城介绍";
    }
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.row == 0) {
        //欢迎页
        YinDaoViewController *daoahang = [[YinDaoViewController alloc] init];
        [self.navigationController pushViewController:daoahang animated:YES];
    }else if(indexPath.row == 1){
        //客服电话
        [_myActionSheet showInView:self.view];
        
    }else if(indexPath.row == 2){
        [_touSuActionSheet showInView:self.view];
    }else{
        
        LibWebViewViewController *lib = [[LibWebViewViewController alloc] init];
        lib.code = @"GYXHN";
        lib.myTitle = @"未涞商城简介";
        [self.navigationController pushViewController:lib animated:YES];
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 40*_kscH;
}
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
    NSLog(@"点击了 %ld",(long)buttonIndex);
    if (buttonIndex != 0) {
        //打电话
//        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:[NSString stringWithFormat:@"tel://%@",[actionSheet buttonTitleAtIndex:buttonIndex]]]];
        [self callWithTellNumber:[actionSheet buttonTitleAtIndex:buttonIndex]];
        
    }
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
